<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Thanh Nguyen Dinh<thanhnguyendinh@admicro.vn>
 * @copyright 2013
 */
class News extends MX_Controller
{
    
    public function __construct()
    {
        parent::__construct();
        $this->load->library('Default_Layout');
        $this->load->library('Minifier');
        $this->load->model('post/post_model');
        
    }

    public function index()    
    {
    	$data = array();
        $data['listNews'] = $this->post_model->get_all_post();
        $this->default_layout->_loadHeader('');   
        $this->load->view('news/news_view',$data);     
        $this->default_layout->_loadFooter();    
    }
    public function view(){
        $id = $this->uri->rsegment(3);
        $data = array();
        $title = "";
        if(is_numeric($id) && $id){
            $data['News'] = $this->post_model->get_post_by_id($id);
            $title = $data['News'][0]['title'];
        }
        //if()
        $this->default_layout->_loadHeader($title);   
        $this->load->view('news/view_view',$data);     
        $this->default_layout->_loadFooter();   
    }
}

?>
